<?php
  namespace Home\Controller;
   use Think\Controller;
   class SearchController extends Controller {
		public function index(){
		
			
		            	 if(IS_POST)
     {
                    $wd=$_POST['keyword'];
                    $m=M('goods');
                    $where['name']=array('like',"%$wd%");
                    $result= $m->where($where)->select();   //->where('ni=0')
                     if($result!==NULL)
                     { 
                       $this->assign('dat',$result); 
                     }else{
                      $result[0]['name']="未找到内容！";
                      $result[0]['comment']="请更换搜索关键字，或者点击右侧给站长留言！";
                      $this->assign('dat',$result); 
                     }
                     
                   
                    $this->display();
     }
     else{
     
     
      $this->error("非法操作！！");
     }
			
			
		}
		
		public function down(){
    
               if(IS_POST)
     {        
            
                $m=M('goods');
                $data['id']=$_POST['id'];
                //$this->success('数据修改成功','index');
                $data['url']=$_POST['url'];
                $data['name']=$_POST['name'];
                $count=$m->save($data);
                if($count>0){
                  $this->ajaxReturn("修改数据成功 !",'eval');
                  }else{
                  $this->ajaxReturn("修改失败！",'eval');
             }
      } elseif(IS_GET){
        $m=M('goods');
        $id['id']=$_GET['id'];
        $data=$m->where($id)->select(); 
        $this->assign('dat',$data);//留言总数
        $this->display();
     }
      else{
      
        $this->error('非法操作哦！');
      }
   }         
}
?>